//
//  ByCellAimMemberPhone.m
//  mijifen_ios
//
//  Created by mc on 2017/11/13.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "ByCellAimMemberPhone.h"

@interface ByCellAimMemberPhone()<UITextFieldDelegate>
@end

@implementation ByCellAimMemberPhone

+ (instancetype)cellWithTableView:(UITableView*)tableView{
    
    static NSString *cellIdentifier = @"ByCellAimMemberPhone";
    ByCellAimMemberPhone *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[self alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    return cell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSeparatorStyleNone;
        self.backgroundColor = [UIColor clearColor];
        [self createViews];
    }
    return self;
}

- (void)createViews{
    UIView *bgView = [[UIView alloc] init];
    [self addSubview:bgView];
    CGFloat width = [@"使用条件：" getSizeOfString:16].width;
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(15 + width));
        make.top.equalTo(@(0));
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH - 15 * 2 - width, 50));
    }];
    bgView.backgroundColor = [UIColor whiteColor];
    
    UITextField *textField = [[UITextField alloc] init];
    [bgView addSubview:textField];
    [textField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(10));
        make.top.equalTo(@(10));
        make.right.equalTo(@(-10));
        make.bottom.equalTo(@(-10));
    }];
    textField.font = FONT(16);
    textField.placeholder = @"请输入会员手机号";
    textField.textAlignment = NSTextAlignmentCenter;
    textField.delegate = self;
}
- (void)textFieldDidEndEditing:(UITextField *)textField{
    if (self.phoneBlock) {
        self.phoneBlock(textField.text);
    }
}
@end
